package seatiger.tomcat.catalina.connector;

import java.io.OutputStreamWriter;
import java.io.PrintWriter;

/**
 * 统一的返回 Writer
 */
@Deprecated
public class ResponseWriter extends PrintWriter {

    /**
     * Writer关联的steam
     */
    private ResponseStream stream = null;

    //将OutputStreamWriter 作为入参
    public ResponseWriter(OutputStreamWriter writer,ResponseStream stream) {
        super(writer);
        this.stream = stream;
        this.stream.setCommit(false);
    }

    @Override
    public void flush() {
        this.stream.setCommit(true);
        super.flush();
        this.stream.setCommit(false);
    }

    @Override
    public void println(int i) {
        super.println(i);
        super.flush();
    }

    @Override
    public void println(char c) {
        super.println(c);
        super.flush();
    }

    @Override
    public void println(long x) {
        super.println(x);
        super.flush();
    }

    @Override
    public void println(float f) {
        super.println(f);
        super.flush();
    }

    @Override
    public void println(char[] c) {
        super.println(c);
        super.flush();
    }

    @Override
    public void println(double d) {
        super.println(d);
        super.flush();
    }

    @Override
    public void println(Object o) {
        super.println(o);
        super.flush();
    }

    @Override
    public void println(String s) {
        super.println(s);
        super.flush();
    }

    @Override
    public void println(boolean b) {
        super.println(b);
        super.flush();
    }

    @Override
    public void print(int i) {
        super.print(i);
        super.flush();
    }

    @Override
    public void write(int c) {
        super.write(c);
        super.flush();
    }

    @Override
    public void write(char[] buf, int off, int len) {
        super.write(buf, off, len);
        super.flush();
    }

    @Override
    public void write(char[] buf) {
        super.write(buf);
        super.flush();
    }

    @Override
    public void write(String s, int off, int len) {
        super.write(s, off, len);
        super.flush();
    }

    @Override
    public void write(String s) {
        super.write(s);
        super.flush();
    }

    @Override
    public void print(boolean b) {
        super.print(b);
        super.flush();
    }

    @Override
    public void print(char c) {
        super.print(c);
        super.flush();
    }

    @Override
    public void print(long l) {
        super.print(l);
        super.flush();
    }

    @Override
    public void print(float f) {
        super.print(f);
        super.flush();
    }

    @Override
    public void print(double d) {
        super.print(d);
        super.flush();
    }

    @Override
    public void print(char[] s) {
        super.print(s);
        super.flush();
    }

    @Override
    public void print(String s) {
        super.print(s);
        super.flush();
    }

    @Override
    public void print(Object obj) {
        super.print(obj);
        super.flush();
    }

    @Override
    public void println() {
        super.println();
        super.flush();
    }
}
